import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *


testCase="DBshop020_添加属性"
# 登录后台管理系统,地址是"http://localhost/dbshop/admin",
firefox=openBrowser("http://localhost/dbshop/admin")
firefox.get(urlAdmin)
#调用自定义函数进行后台的登录
DBshopLoginAdmin(firefox)
# 进入销售管理中的发货单,
DBshopEnterMenu3(firefox,'商品管理','商品属性','属性')

#点击“添加属性”
firefox.find_element_by_xpath("//a[@class='btn btn-small btn-primary']").click()

#处理下拉框，选择“好好学习”的属性组
from selenium.webdriver.support.select import Select
list=Select(firefox.find_element_by_id("attribute_group_id"))
list.select_by_visible_text("好好学习")

#输入属性组名称
firefox.find_element_by_id("attribute_name").send_keys("好好学习")
#属性组的排序中先清空框，然后输入“1”
firefox.find_element_by_id("attribute_sort").clear()
firefox.find_element_by_id("attribute_sort").send_keys("1")
#点击“保存属性组信息”
firefox.find_element_by_xpath("//button").click()

#断言
try:
    firefox.find_element_by_xpath("//td[contains(.,'好好学习')]")
    writeLog("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()